package com.sentiment.obj;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.bson.Document;

/**
 * 爬取的页面的数据结构
 * 
 * @author wjk
 *
 */
public class CrawlingPage {
	// 构造函数
	public CrawlingPage() {
	}

	public CrawlingPage(Document doc) {
		this.crawlingTime = doc.getString("crawlingTime");

//		this.encode = doc.getString("encode");
//		this.html = doc.getString("html");
		this.title = doc.getString("title");
		this.url = doc.getString("url");

		this.id = doc.getString("id");
		this.bySrc = doc.getString("bySrc");
	}

	public CrawlingPage(String bySrc, String id,  String url, String title) {
		super();
		this.crawlingTime = generateCrawlingTime();

//		this.encode = encode;
//		this.html = html;
		this.url = url;
		this.title = title;

		this.id = id;
		this.bySrc = bySrc;
	}

	/**
	 * 根据哪篇原文爬取的页面
	 */
	private String bySrc = "null";
	/**
	 * key:encode val:页面编码类型
	 */
//	private String encode = "utf-8";
	/**
	 * 文章id号 用于索引该文章
	 */
	private String id = "null";

	public String getBySrc() {
		return bySrc;
	}

	public void setBySrc(String bySrc) {
		this.bySrc = bySrc;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

//	public String getEncode() {
//		return encode;
//	}
//
//	public void setEncode(String encode) {
//		this.encode = encode;
//	}

	/**
	 * key:html val:存入本地的html页面文件名
	 */
//	private String html = "null";
	/**
	 * key:url val:页面的URL地址
	 */
	private String url = "null";
	/**
	 * key:title val:html页面内的<title>标签内容
	 */
	private String title = "null";
	/**
	 * key:crawlingTime val:页面的爬取时间
	 */
	private String crawlingTime = "null";
	

//	public String getHtml() {
//		return html;
//	}
//
//	public void setHtml(String html) {
//		this.html = html;
//	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getCrawlingTime() {
		return crawlingTime;
	}

	public void setCrawlingTime(String crawlingTime) {
		this.crawlingTime = crawlingTime;
	}


	private String generateCrawlingTime() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日HH:mm:ss");
		return sdf.format(new Date());
	}
}
